<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .box {
      width: 50px;
      height: 50px;
      position: absolute;
      user-select: none;
    }
  </style>
</head>

<body>
  <div class="box" style="top:0; left:0;background: seagreen;">
    <div>Title1</div>
  </div>
  <div class="box" style="top:70px; left:0;background: chartreuse;">
    <div>Title2</div>
  </div>
  <div class="box" style="top:140px; left:0;background: saddlebrown;">
    <div>Title3</div>
  </div>
  <div class="box" style="width:80px;top:210px; left:0;background: salmon;">
    <div>Title4</div>
  </div>
  <div class="box" style="width:100px;top:280px; left:0;background: sandybrown;">
    <div>Title5</div>
  </div>
  <div class="box" style="width:120px;top:350px; height: 20px; left:0;background: skyblue;">
    <div>Title6</div>
  </div>

  <script src="./drag.js"></script>
  <script src="./ref.line.js"></script>
  <script>
    let boxes   = Array.from(document.querySelectorAll('.box'));
    let refLine = new RefLine();
    boxes.forEach(el => {
      const drag = new Drag(el, {
        target: el.firstElementChild
      })
      drag.on('start', function () {
        console.log('start')
      }).on('move', function () {
        console.log('move')
        refLine.check(drag.$el, '.box')
      }).on('end', function () {
        console.log('end')
        refLine.uncheck()
      })
    })
  </script>
</body>

</html>